<?php
namespace app\index\model;
use think\Model;
use app\index\model\House as Hou;
class House extends Model
{
	public function list()
	{
		/*$list = self::where('id','>',0)->select();
		return $list;*/
		$list=new house();
		if(!empty(input('param.name'))){
			$list=$list->where("name","like","%".input("param.name/s")."%");	
		}
		$list=$list->paginate(5,false,['query'=>input('param.')]);
		return $list;

	}
	 public function deleteById($id)
    {
        /*$cla=self::get($id);
        $result = $cla->delete();
        return $result;
        */
        $result = self::destroy($id);//软删除
        return $result;
    }

	 public function add(){

    $data=[
        'name'=>input("param.name"),
		'h_name'=>input("param.h_name"),
		'h_type'=>input("param.h_type"),
		'area'=>input("param.area"),
		'phone'=>input("param.phone"),
		'money'=>input("param.money"),
        'payment'=>input("param.payment"),
		'z_money'=>input("param.z_money"),
		'user_id'=>input("param.user_id"),	
    ];
    $hou = new House();
    $result = $hou->save($data);
    return $result;
}
	public function dan(){
        $id= input("param.id");
        $li=self::select($id);
        return $li;
    }
    public function updateById(){
        $hou=new House();
        $id=input("param.id");
       $data=[
        'name'=>input("param.name"),
		'h_name'=>input("param.h_name"),
		'h_type'=>input("param.h_type"),
		'area'=>input("param.area"),
		'phone'=>input("param.phone"),
		'money'=>input("param.money"),
        'payment'=>input("param.payment"),
		'z_money'=>input("param.z_money"),
		'user_id'=>input("param.user_id"),	
    ];
        $resultt=$hou::get($id)->save($data);
        return $resultt;
    }
}
?>